<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>后台管理系统</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: Arial, sans-serif;
        }
        .container {
            display: flex;
            min-height: 100vh;
        }
        .sidebar {
            width: 220px;
            background-color: #2f4050;
            color: white;
        }
        .content {
            flex: 1;
            display: flex;
            flex-direction: column;
        }
        .header {
            height: 50px;
            background-color: #f3f3f4;
            border-bottom: 1px solid #e7eaec;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            padding: 0 20px;
        }
        .main-content {
            flex: 1;
            padding: 20px;
            background-color: #f3f3f4;
        }
        .menu {
            padding: 20px 0;
        }
        .menu-title {
            padding: 15px 20px;
            font-size: 18px;
            border-bottom: 1px solid #3d4957;
        }
        .menu-item {
            padding: 12px 20px;
            cursor: pointer;
            transition: background-color 0.3s;
            display: flex;
            align-items: center;
        }
        .menu-item i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
        }
        .menu-item:hover {
            background-color: #293846;
        }
        .menu-item.active {
            background-color: #293846;
        }
        .user-info {
            display: flex;
            align-items: center;
        }
        .user-info span {
            margin-right: 10px;
        }
        .logout-btn {
            padding: 5px 15px;
            background-color: #2f4050;
            color: white;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            display: flex;
            align-items: center;
        }
        .logout-btn i {
            margin-right: 5px;
        }
        .logout-btn:hover {
            background-color: #293846;
        }
        iframe {
            width: 100%;
            height: 100%;
            border: none;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="sidebar">
            <div class="menu-title">
                <i class="fas fa-university"></i>
                后台管理系统
            </div>
            <div class="menu">
                <c:if test="${sessionScope.adminUser.roleId == 1}">
                    <div class="menu-item active" onclick="changeMenu(this, '${pageContext.request.contextPath}/admin/news/list')">
                        <i class="fas fa-newspaper"></i>
                        新闻管理
                    </div>
                    <div class="menu-item" onclick="changeMenu(this, '${pageContext.request.contextPath}/admin/campus/list')">
                        <i class="fas fa-school"></i>
                        校园风采
                    </div>
                    <div class="menu-item" onclick="changeMenu(this, '${pageContext.request.contextPath}/admin/user/list')">
                        <i class="fas fa-users"></i>
                        用户管理
                    </div>
                    <div class="menu-item" onclick="changeMenu(this, '${pageContext.request.contextPath}/admin/post/list')">
                        <i class="fas fa-comments"></i>
                        帖子管理
                    </div>
                    <div class="menu-item" onclick="changeMenu(this, '${pageContext.request.contextPath}/admin/feedback/list')">
                        <i class="fas fa-comment-dots"></i>
                        反馈管理
                    </div>
                </c:if>

                <c:if test="${sessionScope.adminUser.roleId == 3}">
                    <div class="menu-item ${sessionScope.adminUser.roleId == 3 ? 'active' : ''}" onclick="changeMenu(this, '${pageContext.request.contextPath}/admin/subject/list')">
                        <i class="fas fa-book"></i>
                        学科管理
                    </div>
                    <div class="menu-item" onclick="changeMenu(this, '${pageContext.request.contextPath}/admin/subject/scores')">
                        <i class="fas fa-graduation-cap"></i>
                        成绩管理
                    </div>
                </c:if>

                <c:if test="${sessionScope.adminUser.roleId == 2}">
                    <div class="menu-item ${sessionScope.adminUser.roleId == 2 ? 'active' : ''}" onclick="changeMenu(this, '${pageContext.request.contextPath}/admin/score/my')">
                        <i class="fas fa-chart-line"></i>
                        我的成绩
                    </div>
                    <div class="menu-item" onclick="changeMenu(this, '${pageContext.request.contextPath}/admin/schedule/list')">
                        <i class="fas fa-calendar-alt"></i>
                        课程表
                    </div>
                </c:if>
            </div>
        </div>
        <div class="content">
            <div class="header">
                <div class="user-info">
                    <span>欢迎，${sessionScope.adminUser.username}</span>
                    <button class="logout-btn" onclick="location.href='${pageContext.request.contextPath}/admin/logout'">
                        <i class="fas fa-sign-out-alt"></i>
                        退出
                    </button>
                </div>
            </div>
            <div class="main-content">
                <iframe id="contentFrame" src="<c:choose>
                    <c:when test="${sessionScope.adminUser.roleId == 1}">${pageContext.request.contextPath}/admin/news/list</c:when>
                    <c:when test="${sessionScope.adminUser.roleId == 2}">${pageContext.request.contextPath}/admin/score/my</c:when>
                    <c:when test="${sessionScope.adminUser.roleId == 3}">${pageContext.request.contextPath}/admin/subject/list</c:when>
                </c:choose>" frameborder="0"></iframe>
            </div>
        </div>
    </div>
    <script>
        function changeMenu(element, page) {
            // 移除其他菜单项的active类
            document.querySelectorAll('.menu-item').forEach(item => {
                item.classList.remove('active');
            });
            // 添加当前菜单项的active类
            element.classList.add('active');
            // 更改iframe的src
            document.getElementById('contentFrame').src = page;
        }
    </script>
</body>
</html> 